namespace Collaboris.Saf.Actions.Wss.Tests.Generated
{
    using Engine.Report;

    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Saf.Tests;

    using SharePoint.Wss.Security;

    using Wss.Wrappers;

    /// <summary>
    /// This test was originally generated but has now been tested and verfiied by MJ
    /// </summary>
    [TestClass]
    public class StsAdminTest
    {

        [TestMethod]
        public void StsAdmin_Test()
        {
            var stsadmin =
                    new WSSTestAssistant<StsAdmin, WSSExternalEngineWrapper<Entities.StsAdminCommand>>
                        (TestEnvironment.PublishingSite, "StsAdminTestWeb", "BLANKINTERNET#0");

            using (stsadmin)
            {
                if (SecurityHelper.GroupExists(stsadmin.TestSite.RootWeb, "SAF Demo Group"))
                    SecurityHelper.RemoveGroup(stsadmin.TestWeb, "SAF Demo Group");

                stsadmin.FirstEntity.DoScript.Arguments["url"] = stsadmin.TestWeb.Url;

                MacroReport doReport = stsadmin.DoMacro();

                Assert.IsNotNull(SecurityHelper.GetSiteGroup("SAF Demo Group", stsadmin.TestWeb));

                stsadmin.FirstEntity.UndoScript.Operation = "deleteGroup";
                stsadmin.FirstEntity.UndoScript.Arguments.Clear();
                stsadmin.FirstEntity.UndoScript.Arguments.Add("url", stsadmin.TestWeb.Url);
                stsadmin.FirstEntity.UndoScript.Arguments.Add("name", "SAF Demo Group");
                MacroReport undoReport = stsadmin.UndoMacro();

                //stsadmin doesn't work - the group is still there after deleting!
                // Assert.IsNull(SecurityHelper.GetSiteGroup("SAF Demo Group", stsadmin.TestWeb));
            }
        }

    }
}
